package com.dongecloud.provider;

import com.donge.api.IUserService;
import com.donge.bean.User;
import io.github.resilience4j.ratelimiter.annotation.RateLimiter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
public class HelloController implements IUserService {
    @Value("${server.port}")
    private Integer port;
    @Override
    @RateLimiter(name="rlA")
    public String hello(){
        System.out.println("来了，老弟" + new Date());
        //int i= 1/0;
        return "hello cloud"+ port;
    }

    @Override
    public String hello1(String name){
        return "hello" + name;
    }

    @PostMapping("/user1")
    public User addUser1(User user){
        return user;
    }

    @Override
    public User addUser2( @RequestBody  User user){
        return user;
    }

    @PutMapping("/user1")
    public void updateUser1(User user){
        System.out.println("user1:"+user);
    }

    @Override
    public void updateUser2( @RequestBody  User user){
        System.out.println("user2:"+user);
    }

    @DeleteMapping("/user1")
    public void deleteUser1(Integer id){
        System.out.println("user1:"+id);
    }

    @Override
    public void deleteUser2(@PathVariable Integer id){
        System.out.println("user2:"+id);
    }
}
